#!/usr/bin/env python3.10
# -*- encoding: utf-8 -*-
'''
@File    :   comment.py
@Time    :   2023/05/08 09:46:24
@Author  :   windstarry 
@Version :   1.0
'''
# here put the import lib
from tortoise import fields
from .base import BaseModel

class CommentModel(BaseModel):
    from_admin = fields.BooleanField(default=False,description="是否为管理员的评论")
    is_reviewed = fields.BooleanField(default=False, description="评论是否通过审核")
    author = fields.CharField(max_length=30, description="评论者")
    email = fields.CharField(max_length=254, description="评论者邮箱")
    body = fields.TextField(description="评论内容")
    post = fields.ForeignKeyField('models.PostModel', related_name='comments', on_delete='CASCADE')
    parent_id = fields.IntField(default=0, description="父评论ID")
    replies = fields.ReverseRelation['CommentModel']
    replied = fields.ForeignKeyField('models.CommentModel',default=None,null=True,on_delete="CASCADE")
    
    class Meta:
        table = "sys_comments"
        table_description = "评论表"  